import React, { Component } from 'react';
import Message from '../../components/Message'
import Wallet from '../../components/Wallet'
import Application from '../../components/Application'
import Trade from '../../components/Trade'
import { home } from './home'
import { connect } from 'react-redux'
import { homeAction } from '../../store/actionCreators'
import { NoticeBar } from 'antd-mobile'
import './home.css'

const mapStateToProps = (state) => ({
    info: state.info
})
const mapDispatchToProps = (dispatch) => ({
    getIndex: (data) => dispatch(homeAction(data))
})

class Home extends Component {
    componentDidMount() {
        home().then(res => {
            this.props.getIndex(res.data.member_info)
        })
    }
    render() {
        return (
            <div className="home">
                <Message info={this.props.info} />
                <NoticeBar
                    mode='link'
                    marqueeProps={{
                        loop: true, style: {
                            padding: '0 7.5px',
                        }
                    }}
                    onClick={() => console.log(this.props)}
                    className="noticeBar"
                >
                    由于提现到账日延迟提醒发出通知
                </NoticeBar>
                <Wallet info={this.props.info} />
                <Application />
                <Trade />
            </div >
        )
    }
}

export default connect(mapStateToProps, mapDispatchToProps)(Home);